/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.agenda.model.entity;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Ronildo
 */
@Entity
@Table(name = "AM_TB_MEDI")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "AmTbMedi.findAll", query = "SELECT a FROM AmTbMedi a"),
    @NamedQuery(name = "AmTbMedi.findByCdMedi", query = "SELECT a FROM AmTbMedi a WHERE a.cdMedi = :cdMedi"),
    @NamedQuery(name = "AmTbMedi.findByNmMedi", query = "SELECT a FROM AmTbMedi a WHERE a.nmMedi = :nmMedi"),
    @NamedQuery(name = "AmTbMedi.findByNrCpf", query = "SELECT a FROM AmTbMedi a WHERE a.nrCpf = :nrCpf"),
    @NamedQuery(name = "AmTbMedi.findByNrCrm", query = "SELECT a FROM AmTbMedi a WHERE a.nrCrm = :nrCrm"),
    @NamedQuery(name = "AmTbMedi.findByDtNasc", query = "SELECT a FROM AmTbMedi a WHERE a.dtNasc = :dtNasc"),
    @NamedQuery(name = "AmTbMedi.findByDtCada", query = "SELECT a FROM AmTbMedi a WHERE a.dtCada = :dtCada")})
public class AmTbMedi implements Serializable {
    private static final long serialVersionUID = 1L;
    
    @Id
    @Basic(optional = false)
    @Column(name = "CD_MEDI")
    @GeneratedValue(strategy=GenerationType.SEQUENCE, generator = "seq_AM_TB_MEDI")
    @SequenceGenerator(name="seq_AM_TB_MEDI", sequenceName = "seq_AM_TB_MEDI")
    private Integer cdMedi;
    
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 40)
    @Column(name = "NM_MEDI")
    private String nmMedi;
    @Basic(optional = false)
    @NotNull
    @Column(name = "NR_CPF")
    private long nrCpf;
    @Basic(optional = false)
    @NotNull
    @Column(name = "NR_CRM")
    private long nrCrm;
    @Basic(optional = false)
    @NotNull
    @Column(name = "DT_NASC")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dtNasc;
    @Basic(optional = false)
    @NotNull
    @Column(name = "DT_CADA")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dtCada;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "amTbMedi")
    private Collection<AmTbMediPlanSaud> amTbMediPlanSaudCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "amTbMedi")
    private Collection<AmTbUsuaSistMedi> amTbUsuaSistMediCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "amTbMedi")
    private Collection<AmTbMediEspe> amTbMediEspeCollection;

    public AmTbMedi() {
    }

    public AmTbMedi(Integer cdMedi) {
        this.cdMedi = cdMedi;
    }

    public AmTbMedi(Integer cdMedi, String nmMedi, long nrCpf, long nrCrm, Date dtNasc, Date dtCada) {
        this.cdMedi = cdMedi;
        this.nmMedi = nmMedi;
        this.nrCpf = nrCpf;
        this.nrCrm = nrCrm;
        this.dtNasc = dtNasc;
        this.dtCada = dtCada;
    }

    public Integer getCdMedi() {
        return cdMedi;
    }

    public void setCdMedi(Integer cdMedi) {
        this.cdMedi = cdMedi;
    }

    public String getNmMedi() {
        return nmMedi;
    }

    public void setNmMedi(String nmMedi) {
        this.nmMedi = nmMedi;
    }

    public long getNrCpf() {
        return nrCpf;
    }

    public void setNrCpf(long nrCpf) {
        this.nrCpf = nrCpf;
    }

    public long getNrCrm() {
        return nrCrm;
    }

    public void setNrCrm(long nrCrm) {
        this.nrCrm = nrCrm;
    }

    public Date getDtNasc() {
        return dtNasc;
    }

    public void setDtNasc(Date dtNasc) {
        this.dtNasc = dtNasc;
    }

    public Date getDtCada() {
        return dtCada;
    }

    public void setDtCada(Date dtCada) {
        this.dtCada = dtCada;
    }

    @XmlTransient
    public Collection<AmTbMediPlanSaud> getAmTbMediPlanSaudCollection() {
        return amTbMediPlanSaudCollection;
    }

    public void setAmTbMediPlanSaudCollection(Collection<AmTbMediPlanSaud> amTbMediPlanSaudCollection) {
        this.amTbMediPlanSaudCollection = amTbMediPlanSaudCollection;
    }

    @XmlTransient
    public Collection<AmTbUsuaSistMedi> getAmTbUsuaSistMediCollection() {
        return amTbUsuaSistMediCollection;
    }

    public void setAmTbUsuaSistMediCollection(Collection<AmTbUsuaSistMedi> amTbUsuaSistMediCollection) {
        this.amTbUsuaSistMediCollection = amTbUsuaSistMediCollection;
    }

    @XmlTransient
    public Collection<AmTbMediEspe> getAmTbMediEspeCollection() {
        return amTbMediEspeCollection;
    }

    public void setAmTbMediEspeCollection(Collection<AmTbMediEspe> amTbMediEspeCollection) {
        this.amTbMediEspeCollection = amTbMediEspeCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (cdMedi != null ? cdMedi.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof AmTbMedi)) {
            return false;
        }
        AmTbMedi other = (AmTbMedi) object;
        if ((this.cdMedi == null && other.cdMedi != null) || (this.cdMedi != null && !this.cdMedi.equals(other.cdMedi))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.agenda.model.entity.AmTbMedi[ cdMedi=" + cdMedi + " ]";
    }
    
}
